package com.itheima.view.views;

import javax.swing.*;
import java.awt.*;

public class JPanelExample extends JFrame {
    JButton[]buttons;
    JPanel panel1;
    CustomPanel panel2;
    public JPanelExample (){
        super ("面板实例");
        this.setLayout(new FlowLayout());//创建一个流布局管理面板
        buttons=new JButton[4 ];
        for (int i = 0; i < buttons.length; i++) {
            buttons[i] =new JButton("按钮"+(i+1));
            panel1.add(buttons[i]);
            //添加按钮到panel1中
        }
        panel2= new CustomPanel(300, 300, 300, 200);//实例化类对象，设置参数
     //panel2.setPerferredSize(new Dimension(300,200));//设置面板的大小
panel2.setVisible(true);



    }
}
